/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pbpm.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.itttq.gshop.domain.po.WareInfoPo;
import com.itttq.gshop.domain.to.IndexStatTo;
import com.itttq.gshop.pbpm.cmpt.mybatis.CustomInLanguage;
import com.itttq.gshop.pbpm.provider.WareInfoSqlProvider;

@Mapper
public interface IWareInfoMapper {
	/**
	 * 新增WareInfoPo对象
	 * 
	 * @param WareInfoPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@InsertProvider(type=WareInfoSqlProvider.class,  method="addWareInfo") 
	public Integer addWareInfo(WareInfoPo wareInfo);

	/**
	 * 更新WareInfoPo对象
	 * 
	 * @param wareInfoPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@UpdateProvider(type=WareInfoSqlProvider.class,  method="updateWareInfo") 
	public Integer updateWareInfo(WareInfoPo wareInfo);
	
	/**
	 * 根据ID删除WareInfoPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return Integer
	 */
	@DeleteProvider(type=WareInfoSqlProvider.class,  method="delWareInfo") 
	public Integer delWareInfoById(Integer id);

	/**
	 * 根据IDS删除WareInfoPo对象
	 * 
	 * @param ids
	 * @Author 迷蝶
	 * @return List<WareInfoPo>
	 */
	@Lang(CustomInLanguage.class)
	@Delete("DELETE FROM ware_info WHERE id IN (#{ids})")
	public Integer delWareInfoByIds(@Param("ids") List<Integer> ids);
	
	/**
	 * 根据条件查找WareInfoPo对象，默认根据ID降序
	 * 
	 * @param wareInfoPo
	 * @Author 迷蝶
	 * @return List<WareInfoPo>
	 */
	@SelectProvider(type=WareInfoSqlProvider.class,  method="findWareInfos") 
	public List<WareInfoPo> findWareInfos(WareInfoPo wareInfo);
	
	/**
	 * 根据条件查找记录总数
	 * 
	 * @param wareInfoPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@SelectProvider(type=WareInfoSqlProvider.class,  method="findWareInfoCount") 
	public Integer findWareInfoCount(WareInfoPo wareInfo);

	/**
	 * 根据ID查找WareInfoPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return WareInfoPo
	 */
	@SelectProvider(type=WareInfoSqlProvider.class,  method="findWareInfoById") 
	public WareInfoPo findWareInfoById(Integer id);

	/**
	 * 获取今天新增商品
	 * 
	 * @Author 迷蝶
	 * @return IndexStatTo
	 */
	@Select("select count(*) as countToday from ware_info where TO_DAYS(NOW( )) = TO_DAYS(create_time)") 
	public IndexStatTo findWareCountToday();

	/**
	 * 根据ID集合查找WareInfoPo对象
	 * 
	 * @param ids
	 * @Author 迷蝶
	 * @return List<WareInfoPo>
	 */
	@Lang(CustomInLanguage.class)
	@Select("SELECT id,number_inventory, name FROM ware_info WHERE id IN (#{ids})") 
	public List<WareInfoPo> findWareByIds(@Param("ids") List<Integer> ids);
	
	/**
	 * 根据商品ID条件批量更新商品库存数据。
	 * 
	 * @param map	key值为deduct表示扣减；key为return表示还回库存。value为商品对象，必须含ID、numberInventory。注意：此时传入的商品库存值为要扣减的库存
	 * @Author 迷蝶
	 * @return Integer
	 */
	@UpdateProvider(type=WareInfoSqlProvider.class,  method="updateInventoryBatch") 
	public Integer updateInventoryBatch(Map<String, List<WareInfoPo>> map);
}